home *** CD-ROM | disk | FTP | other *** search
/ BCI NET 2 / BCI NET 2.iso / archives / programming / asm / adisv1_3.lha / src / opcode_handler_mmu.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-09-24  |  5.1 KB  |  218 lines

  1. /*
  2.  * Change history
  3.  * $Log:    opcode_handler_mmu.c,v $
  4.  * Revision 3.0  93/09/24  17:54:17  Martin_Apel
  5.  * New feature: Added extra 68040 FPU opcodes
  6.  * 
  7.  * Revision 2.4  93/07/18  22:56:27  Martin_Apel
  8.  * *** empty log message ***
  9.  * 
  10.  * Revision 2.3  93/07/11  21:39:02  Martin_Apel
  11.  * Bug fix: Changed PTEST function for 68030
  12.  * 
  13.  * Revision 2.2  93/07/08  22:29:17  Martin_Apel
  14.  * 
  15.  * Bug fix: Fixed PFLUSH bug. Mode and mask bits were confused
  16.  * 
  17.  * Revision 2.1  93/07/08  20:49:34  Martin_Apel
  18.  * Bug fixes: Fixed various bugs regarding 68030 opcodes
  19.  * 
  20.  * Revision 2.0  93/07/01  11:54:31  Martin_Apel
  21.  * *** empty log message ***
  22.  * 
  23.  * Revision 1.3  93/07/01  11:42:59  Martin_Apel
  24.  * 
  25.  * Revision 1.2  93/06/19  12:11:49  Martin_Apel
  26.  * Major mod.: Added full 68030/040 support
  27.  * 
  28.  * Revision 1.1  93/06/16  20:29:09  Martin_Apel
  29.  * Initial revision
  30.  * 
  31.  */
  32.  
  33. #include <string.h>
  34. #include "defs.h"
  35.  
  36. static char rcsid [] = "$Id: opcode_handler_mmu.c,v 3.0 93/09/24 17:54:17 Martin_Apel Exp $";
  37.  
  38. /**********************************************************************/
  39.  
  40. int pflush40 (struct opcode_entry *op)
  41.  
  42. {
  43. if (pass3)
  44.   {
  45.   switch ((*code >> 3) & 0x3)
  46.     {
  47.     case 0: strcat (opcode, "N");  break;
  48.     case 1:                        break;
  49.     case 2: strcat (opcode, "AN"); break;
  50.     case 3: strcat (opcode, "A");  break;
  51.     }
  52.   if ((*code & 0x10) == 0)
  53.     indirect (src, (short)(REG_NUM (*code) + 8));
  54.   }
  55. return (1);
  56. }
  57.  
  58. /**********************************************************************/
  59.  
  60. int ptest40 (struct opcode_entry *op)
  61.  
  62. {
  63. if (pass3)
  64.   {
  65.   if (*code & 0x20)
  66.     strcat (opcode, "R");
  67.   else
  68.     strcat (opcode, "W");
  69.   indirect (src, (short)(REG_NUM (*code) + 8));
  70.   }
  71. return (1);
  72. }
  73.  
  74. /**********************************************************************/
  75.  
  76. static BOOL eval_fc (char *to)
  77.  
  78. {
  79. if ((*(code + 1) & 0x0018) == 0x0010)
  80.   immed (to, (long)(*(code + 1) & 0x7));
  81. else if ((*(code + 1) & 0x0018) == 0x0008)
  82.   strcpy (to, reg_names [*(code + 1) & 0x7]);
  83. else if ((*(code + 1) & 0x001f) == 0)
  84.   strcpy (to, special_regs [SFC]);
  85. else if ((*(code + 1) & 0x001f) == 0x0001)
  86.   strcpy (to, special_regs [DFC]);
  87. else return (FALSE);
  88. return (TRUE);
  89. }
  90.  
  91. /**********************************************************************/
  92.  
  93. int mmu30 (struct opcode_entry *op)
  94.  
  95. {
  96. /* Test for PTEST instruction */
  97. if (((*(code + 1) & 0xfc00) == 0x9c00) && ((*code & 0x003f) != 0))
  98.   return ptest30 (op);
  99. else if (!(*(code + 1) & 0x8000))
  100.   {
  101.   op = &(mmu_opcode_table [*(code + 1) >> 10]);
  102.   if (pass3)
  103.     strcpy (opcode, op->mnemonic);
  104.   return ((*op->handler) (op));
  105.   }
  106. return (TRANSFER);
  107. }
  108.  
  109. /**********************************************************************/
  110.  
  111. int ptest30 (struct opcode_entry *op)
  112.  
  113. {
  114. if ((*code & 0x003f) == 0)         /* Check for illegal mode */
  115.   return (TRANSFER);
  116.  
  117. strcpy (opcode, "PTESTWFC");
  118. if (*(code + 1) & 0x0200)
  119.   opcode [5] = 'R';
  120. if (!eval_fc (dest))     
  121.   return (TRANSFER);
  122. if (*(code + 1) & 0x0100)
  123.   {
  124.   strcat (dest, ",");
  125.   strcat (dest, reg_names [(*(code + 1) >> 5) & 0x7]);
  126.   }
  127. return (2 + decode_ea (MODE_NUM (*code), REG_NUM (*code),
  128.                       dest, ACC_UNKNOWN, (short)2));
  129. }
  130.  
  131. /**********************************************************************/
  132.  
  133. int pfl_or_ld (struct opcode_entry *op)
  134.  
  135. /* Tests for PLOAD instruction first. Otherwise it's a standard
  136.    PFLUSH instruction */
  137. {
  138. if ((*(code + 1) & 0x00e0) != 0x0000)
  139.   return (pflush30 (op));
  140.  
  141. if ((*code & 0x3f) == 0)
  142.   return (TRANSFER);
  143.  
  144. strcpy (opcode, "PLOAD");
  145. if (*(code + 1) & 0x0200)
  146.   strcat (opcode, "R");
  147. else
  148.   strcat (opcode, "W");
  149.  
  150. if (!eval_fc (src))
  151.   return (TRANSFER);
  152. return (2 + decode_ea (MODE_NUM (*code), REG_NUM (*code),
  153.                        dest, ACC_UNKNOWN, (short)2));
  154. }
  155.  
  156. /**********************************************************************/
  157.  
  158. int pflush30 (struct opcode_entry *op)
  159.  
  160. {
  161. switch (op->param)
  162.   {
  163.   case 1: /* PFLUSHA */
  164.           if (*(code + 1) != 0x2400)
  165.             return (TRANSFER);
  166.           strcat (opcode, "A");
  167.           return (2);
  168.   case 4: /* PFLUSH FC,MASK */
  169.           /* EA ignored !?! */
  170.           if (!eval_fc (src))
  171.             return (TRANSFER);
  172.           immed (dest, (long)((*(code + 1) >> 5) & 0x7));
  173.           return (2);
  174.  
  175.   case 6: /* PFLUSH FC,MASK,EA */
  176.           if (!eval_fc (src))
  177.             return (TRANSFER);
  178.           strcat (src, ",");
  179.           immed (src + strlen (src), (long)((*(code + 1) >> 5) & 0x7));
  180.           return (2 + decode_ea (MODE_NUM (*code), REG_NUM (*code),
  181.                                  dest, ACC_UNKNOWN, (short)2));
  182.   }
  183.  
  184. return (TRANSFER);
  185. }
  186.  
  187. /**********************************************************************/
  188.  
  189. int pmove30 (struct opcode_entry *op)
  190.  
  191. {
  192. char *ea,
  193.      *reg;
  194.  
  195. if ((*code & 0x003f) == 0)
  196.   return (TRANSFER);
  197.  
  198. if ((*(code + 1) & 0xff) || ((*(code + 1) & 0x0010) && op->param == MMUSR))
  199.   return (TRANSFER);
  200.  
  201. if (*(code + 1) & 0x0200)
  202.   {
  203.   ea = dest;
  204.   reg = src;
  205.   }
  206. else
  207.   {
  208.   ea = src;
  209.   reg = dest;
  210.   }
  211. if ((*(code + 1) & 0x0100))
  212.   strcat (opcode, "FD");
  213.  
  214. strcpy (reg, special_regs [op->param]);
  215. return (2 + decode_ea (MODE_NUM (*code), REG_NUM (*code),
  216.                        ea, ACC_LONG, (short)2));
  217. }
  218.